/*
 * @Descripttion: 
 * @version: 
 * @Author: 高月飞
 * @Date: 2023-11-17 21:34:02
 * @LastEditors: 高月飞
 * @LastEditTime: 2023-11-22 22:21:32
 */

//网络请求

import { userCustomervestMessageApi } from "@/services/customer";
import { defineStore } from "pinia";

import type { ICustomerData } from "@/types/customer";
const useVistStore = defineStore('vist', {
    //持久化操作
    //对于登录信息进行一次持久化操作
    persist: {
        storage: window.sessionStorage,
        paths: ['vistinfo']
    },

    state: () => ({
        vistinfo: {
            currentOwnership: "",
            originalBelonging: "",
            operator: "",
            endTime: "",
            operationMethod: "",
            startingTime: "",
            operatingTime: " "
        }
    }) as ICustomerData.IRootstore3,

    actions: {
        SETVISTINFO(data: ICustomerData.IRootInterface3) {
            this.vistinfo = data
        },
        SETUSERLOGOUT() {
            this.vistinfo = {
                currentOwnership: "",
                originalBelonging: "",
                operator: "",
                endTime: "",
                operationMethod: "",
                startingTime: "",
                operatingTime: " "
            }
        },
        async USEVISTACTION(id: number) {
            console.log("===")
            let ret = await userCustomervestMessageApi(id)
            console.log(ret)
            if (ret.code === 200) {
                this.SETVISTINFO(ret.data)
            }
            return ret.data
        }

    },


})
export default useVistStore
